package com.foreknow.demo5;

import java.util.Scanner;

public class DemoStudent {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        //定义数组容器
        Student[] s = new Student[2];
        for(int i = 0;i<2;i++){
            Student student = new Student();
            System.out.println("请输入学号: ");
            int id = input.nextInt();
            student.setId(id);
            System.out.println("请输入姓名: ");
            String name = input.next();
            student.setName(name);
            System.out.println("请输入电话: ");
            String phone = input.next();
            student.setPhone(phone);
            System.out.println("请输入邮箱: ");
            String email = input.next();
            student.setEmail(email);
            System.out.println("请输入标题: ");
            String title = input.next();
            student.setTitle(title);
            //每循环一次就向数组中添加一个元素(Student对象)
            s[i] = student;
        }
        //遍历数组输出结果
        for (int i = 0;i<s.length;i++) {
            Student student = s[i];
            System.out.println(student.getName()+ "--" + student.getEmail());
//            System.out.println(s[i].getId() + "--" + s[i].getName());
        }
    }
}
